home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2001 December
/
pcwk12201b.iso
/
Wersje pelne i specjalne
/
Winamp 2.77 i 3.0beta
/
wasabi-sdk_beta1.exe
/
studio
/
Example1
/
example1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2001-10-08
|
7KB
|
199 lines
/*
Nullsoft WASABI Source File License
Copyright 1999-2001 Nullsoft, Inc.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
// ===========================================================================
//
// NULLSOFT WASABI SDK EXAMPLE PROJECTS
//
// File: Example1.cpp
//
// Purpose: Setup the Example1 Component class for our example component
//
// Notes: A note on the comments in this document:
//
// Notes that begin with *** are important notes that everyone
// needs to read. The other comments assist readability or
// explain the thinking behind sections of code which may not
// be immediately obvious to the novice programmer.
//
// Or I'm just typing to hear myself clickyclack. Deal.
//
// Because Example1 is the first of a string of example
// projects, there are more useless comments in this
// set of modules than any others.
//
//
// GOOD MORNING, CAMPERS!
//
// I'm your uncle mig and I'd like to welcome to you Nullsoft's
// Winamp3.0 SDK Camp!
//
// The SDK with a difference! (Never mind the weather)
//
// When you play with Winamp, EVERYTHING is better!
//
//
// For example1, we're gonna just ignore most of this file and
// play with the example1Wnd.cpp file (for the most part).
//
// HOWEVER, there are a handful of things you should know about
// this file first. Most specifically, you gotta edit all the
// "//EDITME" lines. I'll tag out the info as to what all this
// stuff does inline with the code there.
//
//
// Always start with std.h
#include "../common/std.h"
//
#include "example1.h" //EDITME
#include "resource.h"
#include "example1wnd.h" //EDITME
//
#include "../common/xlatstr.h"
#include "../studio/services/servicei.h" // For the service template.
#include "../studio/services/svc_wndcreate.h"
#include "../common/SimpleWndCreate.h"
static WACNAME wac;
WACPARENT *the = &wac;
// *** You MUST use a unique GUID for your WAC files.
//
// Here's where you input the GUID. A GUID is simply a REALLY big random
// number that lets the rest of the world uniquely identify you (oh yah,
// guess what "GUID" stands for, bucko?)
//
// Otherwise, when you run the app, it'll recognize and load all the WAC
// files in the WACS folder, but if you report the same GUID as another
// component, the user'll only be able to control one of them.
//
// If you use the same GUID as some other Winamp3.0 developer,
// people will throw rocks at you. And we'll provide the rocks.
//
// Trust me. This one isn't optional. Do it, and do it NOW.
//
// GUIDGEN.EXE is a utility that comes from Microsoft to help you create
// GUID numerics. If you're running Visual Studio, you can find it in
// the "common\tools" folder. There's also a helpfile in there name of
// guidgen.hlp which should get you going with it. If you need more
// info, try the MSDN site.
//
// *** This is MY GUID. Get your own. {D4F84EAA-4905-4f62-A209-2735769B07A0}
static const GUID guid = //EDITME (hint: use guidgen.exe)
{ 0xd4f84eaa, 0x4905, 0x4f62, { 0xa2, 0x9, 0x27, 0x35, 0x76, 0x9b, 0x7, 0xa0 } };
// ===========================================================================
//
// *** WindowCreationServiceObject for this example.
static waServiceT<svc_windowCreate, ThingerWndCreateSvc< Example1Wnd > > Example1_WndCreateSvc;
//
// This "Fortify" stuff is nice happy memory handling and leak detection.
// You might learn about the specifics of it sometime in the future but,
// for now, change the output .WAC filenames for your debug and release
// files here.
WACNAME::WACNAME() {
#ifdef FORTIFY
FortifySetName("Example1.wac"); // EDITME
FortifyEnterScope();
#endif //FORTIFY
wnd = NULL;
}
WACNAME::~WACNAME() {
#ifdef FORTIFY
FortifyLeaveScope();
#endif
}
//
// *** You need to supply a human readable string for your name, too.
//
// Ah, well, yes. There's one problem with GUIDs. Nobody will be
// able to tell that component {6DC73FE8-6D34-4942-950A-FF2370329BB0}
// is the really kickass breadslicing component you've written for
// Winamp3.0 -- so you gotta actually give it at least a SEMI unique
// name in english, too.
const char *WACNAME::getName() {
return "Example1 Component"; //EDITME
}
GUID WACNAME::getGUID() {
return guid;
}
void WACNAME::onCreate() {
// *** Do startup stuff here that doesn't require you to have a window yet
}
void WACNAME::onRegisterServices() {
// *** Register our window creation service here.
// If we don't do this, we don't get a window.
api->service_register(&Example1_WndCreateSvc);
// In this example we use entirely our window class's guid and name.
api->register_autoPopupGUID(getGUID(), getName());
}
void WACNAME::onDestroy() {
// *** Deregister our window creation service here.
// If we don't do this, we get a memory leak.
api->service_deregister(&Example1_WndCreateSvc);
// *** Be sure to delete all your windows etc HERE, not in the destructor
// because the API pointer might be invalid in the destructor
delete wnd; wnd = NULL;
WACPARENT::onDestroy();
}
//
// *** If the API asks you to make your window, you make your window.
// NO.
// QUESTIONS.
// ASKED.
//
RootWnd *WACNAME::createWindow(int n, RootWnd *parentWnd) {
// *** Ignore the integer parameter behind the curtain.
if (n == 0) {
// I am the one and true Oz.
if (wnd != NULL) return NULL;
wnd = new Example1Wnd;
wnd->init(parentWnd);
return wnd;
}
return 0;
}